﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;

namespace DAO
{
    public class dataconnect
    {
        //laydulieu
        public static DataSet laydulieu(string sql)
        {
            string chuoiketnoi = "provider=microsoft.jet.oledb.4.0; data source=CSDLCNSoft.mdb";
            OleDbConnection con = new OleDbConnection(chuoiketnoi);
            con.Open();
            DataSet ds = new DataSet();
            OleDbDataAdapter da = new OleDbDataAdapter(sql, con);
            da.Fill(ds);      
            con.Close();
            return ds;
        }
        public static bool xulycaulenh(string sql)
        {
            try
            {
                string chuoiketnoi = "provider=microsoft.jet.oledb.4.0; data source=CSDLCNSoft.mdb";
                OleDbConnection con = new OleDbConnection(chuoiketnoi);
                con.Open();
                OleDbCommand cmd = new OleDbCommand();
                cmd.CommandText = sql;
                cmd.Connection = con;
                cmd.CommandType = CommandType.Text;
                cmd.ExecuteNonQuery();
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
